using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace taxi_sovereign.view
{
    public partial class Preferences : Form
    {
        public Preferences()
        {
            InitializeComponent();
        }

        private void Preferences_Load(object sender, EventArgs e)
        {

        }

        private void OKApply()
        {
            Painter.ColorSc.BackgroundColor = pictureBox1.BackColor;
            Painter.ColorSc.VehicleColor = pictureBox2.BackColor;
            Painter.ColorSc.StopColor = pictureBox3.BackColor;
            Painter.ColorSc.StationColor = pictureBox4.BackColor;
            Painter.ColorSc.CrossColor = pictureBox5.BackColor;
            Painter.ColorSc.RoadColor = pictureBox6.BackColor;
            Painter.ColorSc.Chosencolor = pictureBox7.BackColor;
            Painter.ColorSc.Chosenchosencolor = pictureBox8.BackColor;
            controls.ModelCtrl.ModelTimerinterval1 = decimal.ToInt32(numericUpDown1.Value);
            Painter.BusStopText = checkBox2.Checked;
            Painter.VehicleText = checkBox1.Checked;
            Painter.SaveColorSchemaToFile("Colors.tsc");
            controls.ModelCtrl.SaveGeneralPropsToFile("General.tsg");
            Painter.PaintEverything();
        }

        private void Preferences_Load_1(object sender, EventArgs e)
        {
            pictureBox1.BackColor = Painter.ColorSc.BackgroundColor;
            pictureBox2.BackColor = Painter.ColorSc.VehicleColor;
            pictureBox3.BackColor = Painter.ColorSc.StopColor;
            pictureBox4.BackColor = Painter.ColorSc.StationColor;
            pictureBox5.BackColor = Painter.ColorSc.CrossColor;
            pictureBox6.BackColor = Painter.ColorSc.RoadColor;
            pictureBox7.BackColor = Painter.ColorSc.Chosencolor;
            pictureBox8.BackColor = Painter.ColorSc.Chosenchosencolor;
            numericUpDown1.Value = controls.ModelCtrl.ModelTimerinterval1;
            checkBox1.Checked = Painter.VehicleText;
            checkBox2.Checked = Painter.BusStopText;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            OKApply();
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.BackColor = colorDialog1.Color;
            }
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox2.BackColor = colorDialog1.Color;
            }
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox3.BackColor = colorDialog1.Color;
            }
        }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox4.BackColor = colorDialog1.Color;
            }
        }

        private void pictureBox5_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox5.BackColor = colorDialog1.Color;
            }
        }

        private void pictureBox6_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox6.BackColor = colorDialog1.Color;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OKApply();
        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox7_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox7.BackColor = colorDialog1.Color;
            }
        }

        private void pictureBox8_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox8.BackColor = colorDialog1.Color;
            }
        }

    }
}